/**
 * @author 2404559603@qq.com
 * @time 2022-04-18 17:40 PM
 * @description 用于防止你们不知道如何写vuex留下的模板
 */

const state = {
    token: '', // 用户token
    user: {}  // 用户信息
}

const getters = {
    token(_state) {
        return _state.token
    },
    user: _state => _state.user
}

const actions = {
    userAct({ commit }, _id) {
        // TODO 补充获取用户信息的接口
        commit('mutationUser', {id: 'admin', name: '管理员'})
    }
}

const mutations = {
    mutationToken(_state, _token) {
        _state.token = _token
    },
    mutationUser(_state, _user) {
        _state.user = _user
    }
}

export default {
    namespaced: true,
    state,
    getters,
    actions,
    mutations
}